<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body></body>
  <script>
    let url = "https://scriptoj.com/#/problems?offset=100&limit=10";
    console.log(parseQueryString(url));

    function parseQueryString(url) {
      if (typeof url === "string") {
        let obj = {};
        const paramPart = url.replace(/\S*#/, "").match(/\?[^?]+/);
        if (!paramPart) return {};
        const paramGroup = paramPart[0].substr(1).split("&");
        for (let i = 0; i < paramGroup.length; i++) {
          let name = paramGroup[i].split("=")[0];
          let value = paramGroup[i].split("=")[1];
          obj[name] = value;
        }
        return obj;
      } else {
        throw new Error("请输入字符串");
      }
    }
  </script>
</html>
